package com.woniuxy.homepage.core.mapper;

import com.woniuxy.homepage.core.model.CarGoodsActivity;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.woniuxy.homepage.core.vo.CarGoodsActivityVo;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author gmx
 * @since 2021-07-03
 */
public interface CarGoodsActivityMapper extends BaseMapper<CarGoodsActivity> {

    @Select("select * from car_goods_activity where now() between start_time and end_time and status = 0")
    List<CarGoodsActivity> selectByTimeAndStatus();

    @Update("update car_goods_activity set status = #{startStatus} where id = #{id}")
    void updateStatue(Integer id, Integer startStatus);


    List<CarGoodsActivityVo> selectAll(int count);

    @Select("select * from car_goods_activity where goods_id = #{goodsId}")
    CarGoodsActivity selectByGoodsId(Integer goodsId);

    @Select("select * from car_goods_activity where now() > end_time")
    List<CarGoodsActivity> selectByTime();
}
